<template>
	<div class="pages">
		<div class="item_detail">
			<div class="top">
				<div class="item1">订单流程</div>
				<div class="item2">
					<el-button type="primary" @click="" size="small" @click="$router.go(-1)">返回</el-button>
				</div>
			</div>
			<el-steps :active="is_active" align-center>
				<el-step title="合同通过"
					:description="dataForm.coupons.hetong_num?dataForm.coupons.create_time:''"></el-step>
				<el-step title="配货中"
					:description="dataForm.order_info.pay?dataForm.order_info.pay.pay_end_time:''"></el-step>
				<el-step title="已发货" :description="this.dataForm.order.send_time"></el-step>
				<el-step title="验收" :description="dataForm.order_info.shouhuo"></el-step>
			</el-steps>
		</div>
		<div class="item_detail">
			<div class="top">
				<div class="item1">订单信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">订单号</td>
						<td>{{dataForm.order.order_sn}}</td>
						<td class="tit">订单状态</td>
						<td><span>{{getStateName(dataForm.order.status)}}</span></td>
						<td class="tit">创建时间</td>
						<td>{{dataForm.order.create_time}}</td>
					</tr>
					<tr v-if="dataForm.order.send_time">
						<td class="tit">发货信息</td>
						<td>{{dataForm.order.send_text}}</td>
						<td class="tit">发货时间</td>
						<td>{{dataForm.order.send_time}}</td>
						<td class="tit">发货附件</td>
						<td><el-button type="primary" size="small" v-if="dataForm.order.send_fujian"><el-link
									:href="url+dataForm.order.send_fujian" target="_blank" :underline="false"
									style="color: #fff;">点击查看</el-link></el-button></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail">
			<div class="top">
				<div class="item1">企业信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">企业名称</td>
						<td>{{dataForm.order_info.corp_name}}</td>
						<td class="tit">所在地区</td>
						<td>{{CodeToText[dataForm.order_info.corp_provinceId]+CodeToText[dataForm.order_info.corp_cityId]+CodeToText[dataForm.order_info.corp_areaId]}}
						</td>
						<td class="tit">企业实际住所</td>
						<td>{{dataForm.order_info.corp_address}}</td>
					</tr>
					<tr>
						<td class="tit">联系人</td>
						<td>{{dataForm.order_info.corp_contact}}</td>
						<td class="tit">联系电话</td>
						<td>{{dataForm.order_info.corp_mobile}}</td>
						<td class="tit">营业执照</td>
						<td>
							<div v-if="dataForm.order_info.corp_thumb">
								<el-image style="width: 60px; height: 60px" :src="url+dataForm.order_info.corp_thumb"
									:preview-src-list="srcList">
								</el-image>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail">
			<div class="top">
				<div class="item1">需求信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">需求类型</td>
						<td>{{dataForm.order.level==1?'设计研发需求':dataForm.order.level==2?'物资采购需求':'加工制造需求'}}</td>
						<td class="tit">需求名称</td>
						<td>{{dataForm.order.title}}</td>
						<td class="tit">企业名称</td>
						<td>{{dataForm.order_info.corp_name}}</td>
					</tr>
					<tr>
						<td class="tit">联系人</td>
						<td>{{dataForm.order.contact}}</td>
						<td class="tit">联系电话</td>
						<td :colspan="dataForm.order.level==2?3:1">{{dataForm.order.mobile}}</td>
						<td class="tit" v-if="dataForm.order.level==1||dataForm.order.level==3">项目描述</td>
						<td v-if="dataForm.order.level==1">{{dataForm.order.content}}</td>
						<td v-if="dataForm.order.level==3">{{dataForm.order.xiangmu}}</td>
					</tr>
					<tr v-if="dataForm.order.level==2">
						<td class="tit">物资名称</td>
						<td>{{dataForm.order.wuzi}}</td>
						<td class="tit">期望交付时间</td>
						<td>{{dataForm.order.jiaofu_time}}</td>
						<td class="tit">型号和规则</td>
						<td>{{dataForm.order.xinghao}}</td>
					</tr>
					<tr v-if="dataForm.order.level==2">
						<td class="tit">采购数量</td>
						<td colspan="5">{{dataForm.order.c_num}}</td>
					</tr>

					<tr v-if="dataForm.order.level==3">
						<td class="tit">需要完成时间</td>
						<td>{{dataForm.order.end_time}}</td>
						<td class="tit">需求说明</td>
						<td>{{dataForm.order.jiagong}}</td>
						<td class="tit">图纸</td>
						<td>
							<el-button type="primary" size="small" v-if="dataForm.order.thumb"><el-link
									:href="url+dataForm.order.thumb" target="_blank" :underline="false"
									style="color: #fff;">点击查看</el-link></el-button>
						</td>
					</tr>
					<tr v-if="dataForm.order.level==3">
						<td class="tit">数量</td>
						<td colspan="5">{{dataForm.order.j_num}}</td>
					</tr>

					<tr v-if="dataForm.order_info.xiuqiu_shenhe">
						<td class="tit">审核人</td>
						<td>
							<span
								v-if="dataForm.order_info.xiuqiu_shenhe">{{dataForm.order_info.xiuqiu_shenhe.admin_name}}</span>
						</td>
						<td class="tit">审核时间</td>
						<td colspan="3"><span
								v-if="dataForm.order_info.xiuqiu_shenhe">{{dataForm.order_info.xiuqiu_shenhe.create_time}}</span>
						</td>
					</tr>
					<tr v-if="dataForm.order_info.xiuqiu_bohui">
						<td class="tit">审核人</td>
						<td>
							<span
								v-if="dataForm.order_info.xiuqiu_bohui">{{dataForm.order_info.xiuqiu_bohui.admin_name}}</span>
						</td>
						<td class="tit">审核时间</td>
						<td><span
								v-if="dataForm.order_info.xiuqiu_bohui">{{dataForm.order_info.xiuqiu_bohui.create_time}}</span>
						</td>
						<td class="tit">驳回原因</td>
						<td style="color: red;" v-if="dataForm.order_info.xiuqiu_bohui">
							{{dataForm.order_info.xiuqiu_bohui.cause}}
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail" v-if="dataForm.order_info.factory_name">
			<div class="top">
				<div class="item1">工厂信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">工厂名称</td>
						<td>{{dataForm.order_info.factory_name}}</td>
						<td class="tit">工厂地址</td>
						<td>{{dataForm.order_info.factory_address}}</td>
						<td class="tit">联系人</td>
						<td>{{dataForm.order_info.factory_contact}}</td>
					</tr>
					<tr v-if="dataForm.order_info.judan && dataForm.order.status=='-2'">
						<td class="tit">联系电话</td>
						<td>{{dataForm.order_info.factory_mobile}}</td>
						<td class="tit">拒单原因</td>
						<td colspan="3" style="color:red;">{{dataForm.order_info.judan.cause}}</td>
					</tr>
					<tr v-else>
						<td class="tit">联系电话</td>
						<td colspan="5">{{dataForm.order_info.factory_mobile}}</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail" v-if="dataForm.coupons&&dataForm.coupons.hetong_num">
			<div class="top">
				<div class="item1">创制券信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">合同金额(元)</td>
						<td><span v-if="dataForm.coupons">{{dataForm.coupons.hetong_num}}</span></td>
						<td class="tit">服务费用(元)</td>
						<td><span v-if="dataForm.coupons">{{dataForm.coupons.fuwu_num}}</span></td>
						<td class="tit">创制券申请额度(元)</td>
						<td><span v-if="dataForm.coupons">{{dataForm.coupons.coupons_num}}</span></td>
					</tr>
					<tr>
						<td class="tit">合同文件</td>
						<td>
							<div v-if="dataForm.coupons">
								<el-button type="primary" size="small" v-if="dataForm.coupons.thumb"><el-link
										:href="url+dataForm.coupons.thumb" target="_blank" :underline="false"
										style="color: #fff;">打开</el-link></el-button>
							</div>
						</td>
						<td class="tit">申请时间</td>
						<td><span v-if="dataForm.coupons">{{dataForm.coupons.create_time}}</span></td>
						<td class="tit">审核人</td>
						<td>
							<span
								v-if="dataForm.order_info.quan_shenhe">{{dataForm.order_info.quan_shenhe.admin_name}}</span>
						</td>
					</tr>
					<tr>
						<td class="tit">审核时间</td>
						<td><span
								v-if="dataForm.order_info.quan_shenhe">{{dataForm.order_info.quan_shenhe.create_time}}</span>
						</td>
						<!-- 						<td class="tit">审核状态</td>
						<td><el-tag type="success"></el-tag></td> -->
						<td class="tit">备注信息</td>
						<td colspan="3"></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail" v-if="dataForm.order_info.pay">
			<div class="top">
				<div class="item1">打款信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">打款凭证</td>
						<td><el-button type="primary" size="small" v-if="dataForm.order.payment_voucher">
								<el-link :href="url+dataForm.order.payment_voucher" target="_blank" style="color: #fff;"
									:underline="false">点击查看</el-link>
							</el-button></td>
						<td class="tit">上传时间</td>
						<td><span v-if="dataForm.order_info.pay">{{dataForm.order_info.pay.pay_time}}</span></td>
						<td class="tit">确认时间</td>
						<td><span v-if="dataForm.order_info.pay">{{dataForm.order_info.pay.pay_end_time}}</span></td>
					</tr>
					<tr>
						<td class="tit">打款信息</td>
						<td colspan="3">{{dataForm.order.payment_text}}</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="item_detail" v-if="dataForm.order.send_fujian">
			<div class="top">
				<div class="item1">发货信息</div>
			</div>
			<div class="item_table">
				<table width="100%" class="table">
					<tr>
						<td class="tit">发货信息</td>
						<td>{{dataForm.order.send_text}}</td>
						<td class="tit">发货附件</td>
						<td>
							<el-button type="primary" size="small" v-if="dataForm.order.send_fujian">
								<el-link :href="url+dataForm.order.send_fujian" target="_blank" style="color: #fff;"
									:underline="false">点击查看</el-link>
							</el-button>
						</td>
						<td class="tit">发货时间</td>
						<td>{{dataForm.order.send_time}}</td>
					</tr>

				</table>
			</div>
		</div>
		<div style="text-align: right;">

			<el-button type="primary" size="small" @click="edit(dataForm.order.id)"
				v-if="$hasPermission('api/order/edit_xuqiu') && ($store.state.userType==1)">编辑</el-button>
			<el-button type="primary" size="small"
				v-if="($store.state.userType==4 || $store.state.userType==2) && (dataForm.order.status=='0' || dataForm.order.status=='-1')"
				@click="addOrUpdateHandle(dataForm.order.id)">需求编辑</el-button>
			<el-button type="primary" size="small" @click="zuofei(dataForm.order.id)"
				v-if="($store.state.userType==1 || $store.state.userType==2) && dataForm.order.status!='-4'">作废</el-button>
			<el-button type="primary" size="small" @click="shenhe(dataForm.order.id)"
				v-if="dataForm.order.status==0 && $hasPermission('api/order/setField')">审核通过</el-button>
			<el-button type="primary" size="small" @click="bohui(dataForm.order.id)"
				v-if="dataForm.order.status==0 && $hasPermission('api/order/reject')">驳回</el-button>
			<el-button type="primary" size="small" @click="paidan(dataForm.order.id)"
				v-if="dataForm.order.status==1 && $hasPermission('api/order/paidan')">派单</el-button>
			<el-button type="primary" size="small" @click="paidan(dataForm.order.id)"
				v-if="dataForm.order.status=='-2' && $hasPermission('api/order/paidan')">重新派单</el-button>
			<el-button type="primary" size="small" @click="dkpz(dataForm.order.id)"
				v-if="dataForm.order.status==5 && $hasPermission('api/order/payment_voucher')">上传打款凭证</el-button>
			<el-button type="primary" size="small" @click="dkqr(dataForm.order.id)"
				v-if="dataForm.order.status==6 && $hasPermission('api/order/payconfirm')">打款确认</el-button>
			<el-button type="primary" size="small" @click="fahuo(dataForm.order.id)"
				v-if="dataForm.order.status==7 && $hasPermission('api/order/delivery')">订单发货</el-button>
			<!-- 工厂端接单 -->
			<el-button type="primary" size="small" @click="jiedan(dataForm.order.id)"
				v-if="dataForm.order.status==2 && ($hasPermission('api/order/jiedan') || $store.state.userType==1 || $store.state.userType==2)">接单</el-button>
			<el-button type="primary" size="small" @click="judan(dataForm.order.id)"
				v-if="dataForm.order.status==2 && ($hasPermission('api/order/judan') || $store.state.userType==1 || $store.state.userType==2)">拒单</el-button>
			<!-- 企业端确认收货 -->
			<el-button type="primary" size="small" @click="ok_sh(dataForm.order.id)"
				v-if="dataForm.order.status==8 && ($hasPermission('api/order/shouhuo')|| $store.state.userType==1 || $store.state.userType==2)">确认收货</el-button>
			<el-button type="primary" size="small" @click="add_czq(dataForm.order.id)"
				v-if="dataForm.order.status==3 && $hasPermission('api/order/coupons')">申请创制券</el-button>
			<el-button type="primary" size="small" @click="sh_czq(dataForm.order.id)"
				v-if="($store.state.userType==1 || $store.state.userType==2) && dataForm.order.status==4">创制券审核</el-button>
			<el-button type="primary" size="small" @click="bh_czq(dataForm.order.id)"
				v-if="($store.state.userType==1 || $store.state.userType==2) && dataForm.order.status==4">创制券驳回</el-button>
			<el-button type="primary" size="small" @click="edit_czq(dataForm.order.id)"
				v-if="($store.state.userType==1 || $store.state.userType==2 || $store.state.userType==4) && (dataForm.order.status==4 || dataForm.order.status=='-3')">创制券编辑
			</el-button>
		</div>

		<el-dialog title="派单到工厂" :visible.sync="dialogVisible_paidan" :before-close="handleClose" width="640px">
			<div>
				<table width="100%" class="table2">
					<tr>
						<th style="width: 60%;">工厂名称</th>
						<th style="width: 40%;">操作</th>
					</tr>
					<tr v-for="item in factList" :key="item.id">
						<td>{{item.name}}</td>
						<td>
							<el-button type="text" @click="paidan_submit2(item.id)">派单</el-button>
						</td>
					</tr>
				</table>
			</div>
		</el-dialog>

		<el-dialog title="上传打款凭证" :visible.sync="dialogVisible_dkpz" :before-close="handleClose_kdpz" width="640px">
			<div>
				<el-form size="small" label-width="80px" style="padding-right: 150px;">
					<el-form-item label="打款凭证" required>
						<uploadImg :limit="1" url="/api/publics/upload" title="支持图片或pdf格式" accept="image/*,.pdf"
							@saveImgs="saveImg_dkpz" size="10">
						</uploadImg>
					</el-form-item>
					<el-form-item label="打款信息">
						<el-input v-model="dataForm_dkpz.payment_text" placeholder="请输入打款信息"></el-input>
					</el-form-item>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="handleClose_kdpz()" size="small">取 消</el-button>
				<el-button type="primary" size="small" @click="submitForm_dkpz">确 定</el-button>
			</span>
		</el-dialog>


		<el-dialog title="打款信息" :visible.sync="dialogVisible_dkqr" :before-close="handleClose_dkqr" width="640px">
			<div>
				<el-form size="small" label-width="80px">
					<el-form-item label="打款凭证">
						<el-button type="primary" @click="look_dkpz">点击查看</el-button>
					</el-form-item>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="handleClose_dkqr()" size="small">取 消</el-button>
				<el-button type="primary" size="small" @click="submitForm_dkqr">确 定</el-button>
			</span>
		</el-dialog>

		<el-dialog title="发货信息" :visible.sync="dialogVisible_fhxx" :before-close="handleClose_fhxx" width="640px">
			<div>
				<el-form size="small" label-width="80px" :model="dataForm_fhxx" ref="dataForm_fhxx">
					<el-form-item label="发货信息" prop="content">
						<el-input type="textarea" v-model="dataForm_fhxx.content"></el-input>
					</el-form-item>
					<el-form-item label="发货附件">
						<uploadImg :limit="1" url="/api/publics/upload" title="支持图片或pdf格式" accept="image/*,.pdf"
							@saveImgs="saveImg_fhfj" size="10">
						</uploadImg>
					</el-form-item>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="handleClose_fhxx()" size="small">取 消</el-button>
				<el-button type="primary" size="small" @click="submitForm_fhxx">确 定</el-button>
			</span>
		</el-dialog>

		<el-dialog title="申请创制券" :visible.sync="dialogVisible_czq" :before-close="handleClose_czq" width="640px">
			<div>
				<el-form :model="dataForm_czq" size="small" label-width="150px" :rules="rules2" ref="dataForm_czq"
					style="padding-right: 100px;">
					<el-form-item label="企业名称" v-if="!dataForm_czq.id">
						<el-input v-model="dataForm_czq.corp" disabled></el-input>
					</el-form-item>
					<el-form-item label="需求类型" v-if="!dataForm_czq.id">
						<el-input v-model="dataForm_czq.level_name" disabled></el-input>
					</el-form-item>
					<el-form-item label="需求名称" v-if="!dataForm_czq.id">
						<el-input v-model="dataForm_czq.title" disabled></el-input>
					</el-form-item>
					<el-form-item label="工厂名称" v-if="!dataForm_czq.id">
						<el-input v-model="dataForm_czq.factory" disabled></el-input>
					</el-form-item>
					<el-form-item label="合同金额(元)" prop="hetong_num">
						<el-input type="number" v-model="dataForm_czq.hetong_num" placeholder="请输入合同金额(元)"></el-input>
					</el-form-item>
					<el-form-item label="服务费用(元)" prop="fuwu_num">
						<el-input type="number" v-model="dataForm_czq.fuwu_num" placeholder="请输入服务费用(元)"></el-input>
					</el-form-item>
					<el-form-item label="创制券申请额度(元)" prop="coupons_num">
						<el-input type="number" v-model="dataForm_czq.coupons_num" placeholder="创制券申请额度(元)"></el-input>
						<span style="font-size: 12px;color: #999;">创制券申请额度应小于等于服务费用</span>
					</el-form-item>
					<el-form-item label="合同文件" prop="thumb">
						<uploadImg :limit="1" url="/api/publics/upload" title="支持图片或pdf格式" accept="image/*,.pdf"
							@saveImgs="saveImg_czq" size="10" :img="imgList_czq">
						</uploadImg>
					</el-form-item>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="handleClose_czq()" size="small">取 消</el-button>
				<el-button type="primary" size="small" @click="submitForm_czq" v-if="!dataForm_czq.id">确 定</el-button>
				<el-button type="primary" size="small" @click="submitForm_czq2" v-else>确 定</el-button>
			</span>
		</el-dialog>

		<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getinfo"></add-or-update>
	</div>
</template>

<script>
	import AddOrUpdate from './add-or-update'
	import uploadImg from '@/components/uploadImg.vue'
	import {
		provinceAndCityData,
		regionData,
		rovinceAndCityDataPlus,
		regionDataPlus,
		CodeToText,
		TextToCode
	} from "element-china-area-data"
	export default {
		data() {
			const img_czq = (rule, value, callback) => {
				if (!this.dataForm_czq.thumb) {
					callback(new Error('请上传合同文件'))
				} else {
					callback()
				}
			}
			return {
				regionData,
				TextToCode,
				CodeToText,
				url: '',
				is_active: null,
				dataForm: {
					"order": {
						"id": "",
						"order_sn": "",
						"corp_id": "",
						"corp": "",
						"title": "",
						"contact": "",
						"mobile": "",
						"content": "",
						"wuzi": "",
						"jiaofu_time": "",
						"xinghao": "",
						"c_num": "",
						"end_time": "",
						"jiagong": "",
						"j_num": "",
						"thumb": "",
						"xiangmu": "",
						"status": "",
						"level": "",
						"cause": "",
						"create_time": "",
						"factory_id": "",
						"payment_voucher": "",
						"send_time": "",
						"send_text": "",
						"send_fujian": ""
					},
					"order_info": {
						"id": "",
						"order_id": "",
						"corp_id": "",
						"factory_id": "",
						"corp_name": "",
						"corp_provinceId": "",
						"corp_cityId": "",
						"corp_areaId": "",
						"corp_address": "",
						"corp_contact": "",
						"corp_mobile": "",
						"factory_name": "",
						"factory_address": "",
						"factory_contact": "",
						"factory_mobile": "",
						"xiuqiu_shenhe": {
							"admin_name": '',
							"create_time": ''
						},
						"xiuqiu_bohui": {
							"admin_name": '',
							"create_time": '',
							"cause": ''
						},
						"quan_shenhe": {
							"admin_name": '',
							"create_time": ''
						},
						"pay": {
							"pay_time": '',
							"pay_end_time": ''
						}
					},
					"coupons": {
						"hetong_num": '',
						"fuwu_num": '',
						"coupons_num": '',
						"thumb": '',
						"create_time": ''
					},
				},
				stateList: [],
				srcList: [],
				addOrUpdateVisible: false,
				pd_id: '',
				dialogVisible_paidan: false,
				factList: [],
				dataForm_dkpz: {
					id: '',
					thumb: '',
					payment_text: '',
				},
				dialogVisible_dkpz: false,
				dataForm_dkqr: {
					id: ''
				},
				dialogVisible_dkqr: false,
				dialogVisible_fhxx: false,
				dataForm_fhxx: {
					id: '',
					content: '',
					thumb: '',
				},

				dataForm_czq: {
					id: '',
					is_post: 1,
					hetong_num: '',
					fuwu_num: '',
					coupons_num: '',
					thumb: '',
					corp: '',
					level_name: '',
					factory: '',
					title: '',
				},
				rules2: {
					hetong_num: [{
						required: true,
						message: '请输入合同金额',
						trigger: 'blur'
					}],
					fuwu_num: [{
						required: true,
						message: '请输入服务费用',
						trigger: 'blur'
					}],
					coupons_num: [{
						required: true,
						message: '请输入创制券申请额度',
						trigger: 'blur'
					}],
					thumb: [{
						required: true,
						message: '请上传合同文件',
						validator: img_czq,
						trigger: 'change'
					}]
				},
				dialogVisible_czq: false,
				imgList_czq: '',
			}
		},
		components: {
			AddOrUpdate,
			uploadImg
		},
		methods: {
			getStateList() {
				return new Promise((resolve, reject) => {
					this.$http.post('/api/publics/status_list', {}).then(res => {
						this.stateList = res.result
						resolve()
					})
				})

			},
			getStateName(e) {
				let aa = this.stateList.find(res => {
					return res.status == e
				})
				if (aa) {
					return aa.title
				}
			},
			getinfo() {
				this.getStateList().then(res => {
					this.$loading()
					this.$http.post(`/api/order/detail`, {
						id: this.$route.query.id
					}).then(res => {
						this.$closeLoading()
						this.dataForm = {
							...this.dataForm,
							...res.result
						}
						if (this.dataForm.order_info.corp_thumb) {
							this.srcList.push(this.url + this.dataForm.order_info.corp_thumb)
						}
						if (this.dataForm.coupons.hetong_num && this.dataForm.order_info.pay && this
							.dataForm.order
							.send_time && this.dataForm.order_info
							.shouhuo) {
							this.is_active = 4
						} else if (this.dataForm.coupons.hetong_num && this.dataForm.order_info
							.pay && this.dataForm.order.send_time) {
							this.is_active = 3
						} else if (this.dataForm.coupons.hetong_num && this.dataForm.order_info
							.pay.pay_end_time) {
							this.is_active = 2
						} else if (this.dataForm.coupons.hetong_num) {
							this.is_active = 1
						} else {
							this.is_active = null
						}
					})
				})
			},

			//编辑
			edit(id) {
				this.$router.push({
					path: '/order/edit',
					query: {
						id: id
					}
				})
			},
			//需求编辑
			addOrUpdateHandle(id) {
				console.log(id)
				this.addOrUpdateVisible = true
				this.$nextTick(() => {
					this.$refs.addOrUpdate.dataForm.id = id
					this.$refs.addOrUpdate.init()
				})
			},
			//作废
			zuofei(id) {
				this.$confirm('作废后将终止该需求订单，申请创制券的将返还使用额度，请谨慎操作！', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$prompt('作废原因', '提示', {
						showInput: true,
						inputType: 'textarea',
						inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
						inputErrorMessage: '作废原因不能为空!',
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then((param) => {
						this.$loading()
						this.$http.post('/api/order/reject', {
							id: id,
							cause: param.value,
							type: '-4',
						}).then(res => {
							this.$closeLoading()
							this.$message.success(res.msg)
							this.getinfo()
						})
					}).catch(() => {});
				}).catch(() => {});
			},
			//审核通过
			shenhe(id) {
				this.$confirm('是否审核通过?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$loading()
					this.$http.post('/api/order/setField', {
						id: id,
						value: 1
					}).then(res => {
						this.$closeLoading()
						this.$message.success(res.msg)
						this.getinfo()
					})
				}).catch(() => {});
			},
			//驳回
			bohui(id) {
				this.$prompt('驳回原因', '提示', {
					showInput: true,
					inputType: 'textarea',
					inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
					inputErrorMessage: '驳回原因不能为空!',
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then((param) => {
					this.$loading()
					this.$http.post('/api/order/reject', {
						id: id,
						cause: param.value,
						type: '-1',
					}).then(res => {
						this.$closeLoading()
						this.$message.success(res.msg)
						this.getinfo()
					})
				}).catch(() => {});
			},
			//派单到工厂
			paidan(id) {
				this.pd_id = id
				this.dialogVisible_paidan = true
			},
			paidan_submit2(id) {
				let data1 = {
					id: this.pd_id,
					factory_id: id,
				}
				this.$loading()
				this.$http.post('/api/order/paidan', data1).then(res => {
					this.$message({
						message: res.msg,
						type: "success",
						duration: 1000,
						onClose: () => {
							this.$closeLoading()
							this.dialogVisible_paidan = false
							this.getinfo()
							this.pd_id = ''
						}
					});
				})
			},
			handleClose() {
				this.dialogVisible_paidan = false
			},
			handleClose_kdpz() {
				this.dialogVisible_dkpz = false
			},
			//打款凭证
			dkpz(id) {
				this.dialogVisible_dkpz = true
				this.dataForm_dkpz.id = id
			},
			submitForm_dkpz() {
				if (!this.dataForm_dkpz.thumb) {
					return this.$message.error("请上传打款凭证！")
				}
				this.$loading()
				this.$http.post('/api/order/payment_voucher', this.dataForm_dkpz).then(res => {
					this.$closeLoading()
					this.$message({
						message: res.msg,
						type: "success",
						duration: 1000,
						onClose: () => {
							this.getinfo()
							this.dialogVisible_dkpz = false
							this.fileList1 = []
							this.dataForm_dkpz = {
								id: '',
								thumb: '',
								payment_text: '',
							}
						}
					});
				})
			},
			saveImg_dkpz(e) {
				this.dataForm_dkpz.thumb = e
			},
			dkqr(id) {
				this.dialogVisible_dkqr = true
				this.dataForm_dkqr.id = id
			},
			handleClose_dkqr() {
				this.dialogVisible_dkqr = false
			},
			look_dkpz() {
				this.$http.post('/api/order/payconfirm', {
					id: this.dataForm_dkqr.id,
				}).then(res => {
					// console.log(res)
					window.open(process.env.VUE_APP_BASE_API + res.result)
				})
			},
			submitForm_dkqr() {
				this.$loading()
				this.$http.post('/api/order/setField', {
					id: this.dataForm_dkqr.id,
					value: 7
				}).then(res => {
					this.$message({
						message: res.msg,
						type: "success",
						duration: 1000,
						onClose: () => {
							this.$closeLoading()
							this.getinfo()
							this.dialogVisible_dkqr = false
							this.dataForm_dkqr = {
								id: '',
							}
						}
					});
				})
			},
			fahuo(id) {
				this.dialogVisible_fhxx = true
				this.dataForm_fhxx.id = id
			},
			saveImg_fhfj(e) {
				this.dataForm_fhxx.thumb = e
			},
			submitForm_fhxx() {
				if (!this.dataForm_fhxx.content) {
					return this.$message.warning("请填写发货信息！")
				}
				if (!this.dataForm_fhxx.thumb) {
					return this.$message.warning("请上传发货附件！")
				}
				this.$loading()
				this.$http.post('/api/order/delivery', {
					id: this.dataForm_fhxx.id,
					content: this.dataForm_fhxx.content,
					thumb: this.dataForm_fhxx.thumb,
				}).then(res => {
					this.$closeLoading()
					this.$message({
						message: res.msg,
						type: "success",
						duration: 1000,
						onClose: () => {
							this.getinfo()
							this.dialogVisible_fhxx = false
							this.dataForm_fhxx = {
								id: '',
								content: '',
								thumb: ''
							}
						}
					});
				})
			},
			handleClose_fhxx() {
				this.dialogVisible_fhxx = false
			},

			jiedan(id) {
				this.$confirm('是否确认接单?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$loading()
					this.$http.post('/api/order/setField', {
						id: id,
						value: 3
					}).then(res => {
						this.$closeLoading()
						this.$message({
							message: res.msg,
							type: "success",
							duration: 1000,
							onClose: () => {
								this.getinfo()
							}
						});
					})
				}).catch(() => {});
			},
			judan(id) {
				this.$prompt('拒单原因', '提示', {
					showInput: true,
					inputType: 'textarea',
					inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
					inputErrorMessage: '拒单原因不能为空!',
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then((param) => {
					this.$loading()
					this.$http.post('/api/order/reject', {
						id: id,
						cause: param.value,
						type: '-2',
					}).then(res => {
						this.$closeLoading()
						this.$message({
							message: res.msg,
							type: "success",
							duration: 1000,
							onClose: () => {
								this.getinfo()
							}
						});
					})
				}).catch(() => {});
			},
			ok_sh(id) {
				this.$confirm('是否确认收货？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$loading()
					this.$http.post('api/order/shouhuo', {
						id: id,
						value: 9
					}).then(res => {
						this.$closeLoading()
						this.$message({
							message: res.msg,
							type: "success",
							duration: 1000,
							onClose: () => {
								this.getinfo()
							}
						});
					})

				}).catch(() => {});
			},
			add_czq(id) {
				this.$nextTick(() => {
					this.$loading()
				})
				this.dataForm_czq.id = id
				this.$http.post('/api/order/coupons', {
					id: id
				}).then(res => {
					this.$closeLoading()
					this.dataForm_czq.corp = res.result.corp
					this.dataForm_czq.level_name = res.result.level_name
					this.dataForm_czq.factory = res.result.factory
					this.dataForm_czq.title = res.result.title
				})
				this.dialogVisible_czq = true
			},
			handleClose_czq() {
				this.dialogVisible_czq = false
			},

			submitForm_czq() {
				this.$refs['dataForm_czq'].validate((valid) => {
					if (valid) {
						if (!this.dataForm_czq.thumb) {
							return this.$message.error("请上传合同文件！")
						}
						this.$loading()
						this.$http.post('/api/order/coupons', this.dataForm_czq).then(res => {
							this.$closeLoading()
							this.$store.dispatch("userCzqAction")
							this.$message({
								message: res.msg,
								type: 'success',
								duration: 1000,
								onClose: () => {
									this.getinfo()
									this.handleClose_czq()
									this.$refs.dataForm_czq.resetFields()
									this.dataForm_czq.id = ''
								}
							});
						})
					} else {
						return false;
					}
				});
			},
			submitForm_czq2() {
				this.$refs['dataForm_czq'].validate((valid) => {
					if (valid) {
						if (!this.dataForm_czq.thumb) {
							return this.$message.error("请上传合同文件！")
						}
						this.$loading()
						let data = {
							id: this.dataForm_czq.id,
							hetong_num: this.dataForm_czq.hetong_num,
							fuwu_num: this.dataForm_czq.fuwu_num,
							coupons_num: this.dataForm_czq.coupons_num,
							thumb: this.dataForm_czq.thumb,
							is_post: 1
						}
						this.$http.post('/api/order/edit_coupons', data).then(res => {
							this.$closeLoading()
							this.$store.dispatch("userCzqAction")
							this.$message({
								message: res.msg,
								type: 'success',
								duration: 1000,
								onClose: () => {
									this.getinfo()
									this.handleClose_czq()
									this.$refs.dataForm_czq.resetFields()
									this.dataForm_czq.id = ''
								}
							});
						})
					} else {
						return false;
					}
				});
			},
			saveImg_czq(e) {
				this.dataForm_czq.thumb = e
			},

			edit_czq(id) {
				this.$nextTick(() => {
					this.$loading()
				})
				this.$http.post('/api/order/edit_coupons', {
					id: id
				}).then(res => {
					this.$closeLoading()
					this.dataForm_czq = {
						...this.dataForm_czq,
						...res.result
					}
					if (this.dataForm_czq.thumb) {
						this.imgList_czq = {
							name: '合同文件',
							url: process.env.VUE_APP_BASE_API + this.dataForm_czq.thumb
						}
					}
					this.dialogVisible_czq = true
				})

			},
			sh_czq(id) {
				this.$confirm('是否审核通过创制券？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$loading()
					this.$http.post('/api/order/setField', {
						id: id,
						value: 5
					}).then(res => {
						this.$closeLoading()
						this.$store.dispatch("userCzqAction")
						this.$message({
							message: res.msg,
							type: "success",
							duration: 1000,
							onClose: () => {
								this.getinfo()
							}
						});
					})
				}).catch(() => {});
			},
			bh_czq(id) {
				this.$confirm('是否驳回创制券？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$prompt('驳回原因', '提示', {
						showInput: true,
						inputType: 'textarea',
						inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
						inputErrorMessage: '驳回原因不能为空!',
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then((param) => {
						this.$loading()
						this.$http.post('/api/order/reject', {
							id: id,
							cause: param.value,
							type: '-3',
						}).then(res => {
							this.$closeLoading()
							this.$message({
								message: res.msg,
								type: "success",
								duration: 1000,
								onClose: () => {
									this.getinfo()
								}
							});
						})
					}).catch(() => {});
				}).catch(() => {});
			},

			getFactList() {
				this.$http.post('/api/publics/getfactorylist', {
					page: 1,
					limit: 1000
				}).then(res => {
					this.factList = res.result.data
				})
			},
		},
		created() {
			this.url = process.env.VUE_APP_BASE_API
			// this.getStateList()
			this.getinfo()
			this.getFactList()
		}
	}
</script>
<style scoped lang="scss">
	.item_detail {
		margin-bottom: 20px;
		background-color: #fff;
		padding: 20px 25px;

		.top {
			margin-bottom: 20px;
		}
	}

	.pages {
		background: transparent;
		padding: 0;
	}

	.item_table td {
		width: 21.3% !important;
	}

	.item_table td.tit {
		width: 12% !important;
	}

	.table2 {
		border-collapse: collapse;

		th {
			background: #F6F7FA;
			border: 1px solid #ebeef5;
			border-collapse: collapse;
			padding: 10px 0;
			text-align: center;
			line-height: 20px;
			font-size: 14px;
			font-weight: 400;
			color: #333333;
		}

		td {
			border: 1px solid #ebeef5;
			border-collapse: collapse;
			padding: 5px 0;
			text-align: center;
			line-height: 20px;
			font-size: 14px;
			font-weight: 400;
			color: #333333;
		}
	}
</style>